<?php

use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\Commands\CommandController;
use App\Http\Controllers\Servers\ServerController;
use App\Http\Controllers\Servers\ServersController;
use App\Http\Controllers\Servers\ServiceController;
use App\Http\Controllers\Sessions\SessionController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::controller(LoginController::class)->group(function () {
    Route::post('/login', 'handle')->name('login.handle');
    Route::get('/login', 'page')->name('login.page');
});

Route::controller(RegisterController::class)->group(function () {
    Route::post('/register', 'handle')->name('register.handle');
    Route::get('/register', 'page')->name('register.page');
});

Route::prefix('/servers')->controller(ServersController::class)->group(function () {
    Route::get('/list', 'page')->name('servers.list');
    Route::post('/add', 'addServer')->name('servers.add_action');
    Route::get('/add', 'add')->name('servers.add');
    Route::get('/delete', 'delete')->name('servers.delete');
});

Route::prefix('server')->controller(ServerController::class)->group(function () {
    Route::get('/{connection}/{ip}/index', 'page')->name('server.page');
    Route::get('/{connection}/{ip}/session', 'session')->name('server.session');
    Route::get('/{connection}/{ip}/scenarios', 'scenarios')->name('server.scenario');
    Route::get('/{ip}/admin', 'admin')->name('server.admin');
    Route::get('/{ip}/admin/sessions', 'sessionsList')->name('server.admin.sessions');
    Route::get('/{ip}/admin/session/{id}', 'sessionView')->name('server.admin.session.view');
    Route::get('/{connection}/{ip}/session/{service}', 'service')->name('server.service');

});

Route::prefix('server')->controller(ServiceController::class)->group(function () {
    Route::get('/{connection}/{ip}/session/docker/index', 'docker')->name('session.docker.index');
});

Route::prefix('sessions')->controller(SessionController::class)->group(function () {
    Route::get('open', 'openPage')->name('session.open.page');
    Route::post('open', 'open')->name('session.open');
    Route::post('close', 'close')->name('session.close');
    Route::get('get', 'get')->name('session.get');
});

Route::controller(CommandController::class)->group(function () {
})->prefix('command');
